#ifndef MAINWINDOW_H
#define MAINWINDOW_H

#include <QMainWindow>
#include "positionmanager.h"
#include <QLabel>
#include <QPushButton>
#include <QScrollArea>
#include "route_train_dialog.h"

QT_BEGIN_NAMESPACE
namespace Ui { class MainWindow; }
QT_END_NAMESPACE

class MainWindow : public QMainWindow
{
    Q_OBJECT

public:
    explicit MainWindow(QWidget *parent = nullptr);
    ~MainWindow();

    static MainWindow* instance;

    void closeEvent(QCloseEvent *event) override;

    void display_track();

    void setPositionName(const QString &name);

    PositionManager positionManager;

    static LRESULT CALLBACK LowLevelKeyboardProc(int nCode, WPARAM wParam, LPARAM lParam);

    void loadHotKey();
    int vkCode_teleportRole;
    int vkCode_trackRolePos;
    int vkCode_frameRate30;
    int vkCode_frameRate60;
    int vkCode_frameRate90;
    int vkCode_frameRate120;

    void routeTrainDialogClosed();

private slots:
    void on_btn_init_clicked();

    void on_btn_trackRolePos_clicked();

    void on_btn_teleportRolePos_clicked();

    void on_btn_saveCurrentPos_clicked();

    void on_label_drake_linkActivated(const QString &link);

    void on_lineEdit_searchPosStorage_textChanged(const QString &arg1);

    void on_btn_set_teleportRolePos_hotKey_clicked();
    void on_btn_set_trackRolePos_hotKey_clicked();
    void on_btn_set_frameRate30_hotKey_clicked();
    void on_btn_set_frameRate60_hotKey_clicked();
    void on_btn_set_frameRate90_hotKey_clicked();
    void on_btn_set_frameRate120_hotKey_clicked();

    void on_btn_reset_drakePos_clicked();
    void on_btn_pause_resume_drake_clicked();

    void on_languageSelector_currentIndexChanged(int index);

    void on_btn_showRouteTrainDialog_clicked();

private:
    Ui::MainWindow *ui;

    void displayPositions(const QString& searchText = "");
    QList<QLabel*> positionLabels; // Liste pour stocker les labels des positions
    QList<QPushButton*> deleteButtons; // Liste pour stocker les boutons de suppression

    HHOOK hHook;

    RouteTrainDialog* routeTrainDialog = NULL;
};

#endif // MAINWINDOW_H
